package DesignPatern.A22_享元模式.A02_抽象模式;

import java.util.HashMap;

/**
 * @Author: Du
 * @Date: 2021/8/12 14:52
 */
public class FlyWeightFactory
{
    private static HashMap<String, FlyWeight> pool = new HashMap<>();
    
    public static FlyWeight getFlyWeight(String ex)
    {
        FlyWeight flyWeight = null;
        
        if (pool.containsKey(ex))
        {
            flyWeight = pool.get(ex);
        } else
        {
            flyWeight = new ConcreteFlyWeight1(ex);
            pool.put(ex, flyWeight);
        }
        return flyWeight;
    }
    
    
}
